<?php
session_start();

if(isset($_REQUEST['SubCategoryKey']))
{
	$catName=$_REQUEST['cat_name'];
	$catSub=$_REQUEST['sub_cat_name'];
	$subcatDescription=$_REQUEST['subcat_description'];		
	
	$today=date("Y-m-d");		
	$sql_addcat="INSERT INTO tbl_category set parent_id=$catName,category_name='$catSub',category_description='$subcatDescription',created_date='$today'";
	$rst_addcat=mysql_query($sql_addcat);	
	if($rst_addcat) {
		$msgAddScat="Subcategory added Successfully";				
	}	
}
?>
<table width="100%"  border="1" cellspacing="0" class="container">
  <tr>
    <td width="469" height="25" class="tdHeader">Add Subcategory</td>
  </tr>
  <tr>
    <td  height="577">
	<br><br>
              <form action="" method="post" enctype="multipart/form-data" name="formSubCategory" id="formSubCategory">
			  <input type="hidden" name="SubCategoryKey" id="SubCategoryKey">
          <table width="423" height="235" border="0" cellspacing="0" align="center">		   
          <tr>
            <td colspan="3"><div align="center"><?php echo "<b>".$msgAddScat."</b>"; ?></div></td>            
          </tr>
          <tr>
            <td height="29">&nbsp;</td>
            <td><div align="left">Category Name </div></td>
            <td>
              <div align="left">
				<select name="cat_name" id="cat_name" class="fieldMax1">
				              <option value="no">..Select Category..</option> 
			   <?php			   
			   $sqlSelCategory="SELECT * FROM tbl_category where parent_id=0";
			   $rstSelCategory=mysql_query($sqlSelCategory);
			   while($rowSelCategory=mysql_fetch_array($rstSelCategory))
			   {
				   $categoryId=$rowSelCategory['category_id'];
				   $categoryName=$rowSelCategory['category_name'];
				   echo "<option value='$categoryId'>$categoryName</option>";
			   }
			   ?>
               </select>
              </div></td>
          </tr>
		  <tr>
            <td height="29">&nbsp;</td>
            <td><div align="left">Sub Category Name </div></td>
            <td>
              <div align="left">
                <input type="text" name="sub_cat_name" id="sub_cat_name">
              </div></td>
          </tr>  

          <tr>
		  	<td height="29">&nbsp;</td>
            <td>SubCategory Description </td>
            <td><input type="text" name="subcat_description" id="subcat_description"></td>
          </tr>		  
          <tr>
            <td height="65" colspan="3"><div align="center">
                <input name="subCat" type="button" id="subCat" value="Add SubCategory" class="button" onClick="SubCategorySubmit()">
              </div></td>
            </tr>
        </table>
       </form>
      </td>
  </tr>
</table>

